package com.oa.xinxi.dao;

import com.oa.xinxi.entity.Rules;
import org.apache.ibatis.jdbc.SQL;

public class RulesSqlProvider {

    public String insertSelective(Rules record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("rules");
        
        if (record.getRulesId() != null) {
            sql.VALUES("rules_id", "#{rulesId,jdbcType=INTEGER}");
        }
        
        if (record.getTitle() != null) {
            sql.VALUES("title", "#{title,jdbcType=VARCHAR}");
        }
        
        if (record.getCreator() != null) {
            sql.VALUES("creator", "#{creator,jdbcType=VARCHAR}");
        }
        
        if (record.getCreatetime() != null) {
            sql.VALUES("createtime", "#{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdator() != null) {
            sql.VALUES("updator", "#{updator,jdbcType=VARCHAR}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getRulesContent() != null) {
            sql.VALUES("rules_content", "#{rulesContent,jdbcType=LONGVARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Rules record) {
        SQL sql = new SQL();
        sql.UPDATE("rules");
        
        if (record.getTitle() != null) {
            sql.SET("title = #{title,jdbcType=VARCHAR}");
        }
        
        if (record.getCreator() != null) {
            sql.SET("creator = #{creator,jdbcType=VARCHAR}");
        }
        
        if (record.getCreatetime() != null) {
            sql.SET("createtime = #{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdator() != null) {
            sql.SET("updator = #{updator,jdbcType=VARCHAR}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getRulesContent() != null) {
            sql.SET("rules_content = #{rulesContent,jdbcType=LONGVARCHAR}");
        }
        
        sql.WHERE("rules_id = #{rulesId,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}